uniform mat4 gWVP;
uniform mat4 gWorld;

uniform vec4 a_viewport;
attribute vec4 a_position;
attribute vec2 a_texCoord;
attribute vec4 a_color;
varying vec2 v_texCoord;
varying vec4 u_color;
void main()
{	
	//float left,right,bottom,top = a_viewport.xyzw;
	float left = a_viewport[0];
	float right = a_viewport[1];
	float bottom = a_viewport[2];
	float top = a_viewport[3];
	//const float right = a_viewport.x;
 //   const float bottom = a_viewsize.y;
 //   const float left = 0.0;
 //   const float top = 0.0;
    const float far = 1.0;
    const float near = -1.0;
	mat4 ortho_mat = mat4(
		vec4(2.0 / (right - left), 0, 0, 0),
		vec4(0, 2.0 / (top - bottom), 0, 0),
		vec4(0, 0, -2.0 / (far - near), 0),
		vec4(-(right + left) / (right - left), -(top + bottom) / (top - bottom), -(far + near) / (far - near), 1)
	);
	float zr = 45;
	float xr = 36.25;
	//mat4 iso_mat = mat4(vec4(cos(zr),sin(zr),0,0),vec4(-sin(zr),cos(zr),0,0),vec4(0,0,1,0),vec4(0,0,0,1)) 
	//				* mat4(vec4(1,0,0,0),vec4(0,cos(xr),-sin(xr),0),vec4(0,sin(xr),cos(xr),0),vec4(0,0,0,1)) 
	//				* mat4(vec4(1,0,0,0),vec4(0,0,0,0),vec4(0,0,1,0),vec4(0,0,0,1)) ;
	//mat4 iso_mat = mat4(
	//	vec4(0.7071,-0.4082,0,0),
	//	vec4(0,0.8165,0,0),
	//	vec4(-0.7071,-0.4082,0,0),
	//	vec4(0,0,0,1)
	//);
	//mat4 iso_mat = mat4(
	//	vec4(0.9354,-0.1187,0,0),
	//	vec4(0,0.9428,0,0),
	//	vec4(-0.9354,-0.3118,0,0),
	//	vec4(0,0,0,1)
	//);
	a_position = ortho_mat * a_position;
	//float x = a_position.x;
	//float y = a_position.y;
	//float z = a_position.z;
	//const float Y_CORRECT = 1.2247448713915892;
	//a_position.x = x - z;
	//a_position.y = y*Y_CORRECT+(x+z)*0.5;
	//a_position.z = 0;
	u_color = a_color;
	v_texCoord = a_texCoord;
	gl_Position = a_position;
	//gl_Position = a_position;
	//gl_Position = ftransform();
	//gl_Position = gWorld * a_position;
	//gl_Position = gWVP * a_position;
}